#include "Delegate.h"

void testFun1(string str)
{
    cout << "testFun1=======:" << str << endl;
}

void testFun2(string str)
{
    cout << "testFun2=======:" << str << endl;
}

class testfunClass1
{
public:
    void testFun(string str)
    {
        cout << "testfunClass1::testFun=======:" << str << endl;
    }
};

class testfunClass2
{
public:
    void testFun(string str)
    {
        cout << "testfunClass2::testFun=======:" << str << endl;
    }
};

using namespace CXXDelegate;

int main(int argc, char**)
{
    testfunClass1 tsc1;
    testfunClass2 tsc2;
    delegate<void(string)> f;
    f += testFun1;
    f += testFun2;

    f += makeDelegateClassHelper(&testfunClass1::testFun, &tsc1);

    f(string("delegate test string!"));

    OUTPUT(".............................................");
    f -= testFun1;
    f(string("delegate test string2!"));
    OUTPUT(".............................................");
    f -= testFun2;
    f += testFun1;
    f -= makeDelegateClassHelper(&testfunClass1::testFun, &tsc1);
    f(string("delegate test string3!"));
    OUTPUT(".............................................");

    f += makeDelegateClassHelper(&testfunClass2::testFun, &tsc2);
    f(string("delegate test string4!"));
    system("pause");
    return 0;
}